<%--
  Created by IntelliJ IDEA.
  User: wangbin
  Date: 2015/3/3
  Time: 9:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../inc/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <%@ include file="../inc/meta.jsp" %>
    <meta name="description" content="">
    <meta name="author" content="">
    <title>新增客户</title>
    <%@ include file="../inc/css.jsp" %>
</head>
<body>

<div id="posts" class="wrapper">

    <%@ include file="../inc/nav.jsp" %>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">新增客户</h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <form id="formId" method="post" class="form-horizontal" role="form" enctype="multipart/form-data">

                            <input id="id" name="id" type="hidden" value="${customer.id}">

                            <div class="form-group">
                                <label class="col-sm-1 control-label" ><span style="color: red;">* </span>需求号：</label>
                                <div class="col-sm-2">
                                    <input type="text" name="demandNo" value="${customer.demandNo}" class="form-control" data-rule="required"
                                           <c:if test="${customer.id != null}">disabled</c:if>
                                    />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label" >姓名：</label>
                                <div class="col-sm-2">
                                    <input type="text" name="name" value="${customer.name}" class="form-control"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label">电话：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="mobile" name="mobile" value="${customer.mobile}" class="form-control" data-rule="mobile"
                                           data-rule-mobile="[/(^1[34578]\d{9}$)|(^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$)/, '请输入正确的电话']"
                                           <c:if test="${customer.id != null}">disabled</c:if>/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label" >qq：</label>
                                <div class="col-sm-2">
                                    <input type="text" name="qq" value="${customer.qq}" class="form-control"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label" >微信：</label>
                                <div class="col-sm-2">
                                    <input type="text" name="wechat" value="${customer.wechat}" class="form-control"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label" >邮箱：</label>
                                <div class="col-sm-2">
                                    <input type="text" name="email" value="${customer.email}" class="form-control" data-rule="email"
                                           data-rule-email="[/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/, '请输入正确的邮箱']"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label" >地域：</label>
                                <div class="col-sm-2">
                                    <input type="text" name="region" value="${customer.region}" class="form-control"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label" >来源：</label>
                                <div class="col-sm-2">
                                    <input type="text" name="source" value="${customer.source}" class="form-control"
                                           <c:if test="${customer.id != null}">disabled</c:if>/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label" >行业信息：</label>
                                <div class="col-sm-6">
                                    <%--<input type="text" name="industryInfo" value="${customer.industryInfo}" class="form-control"--%>
                                    <%--<c:if test="${customer.id != null}">disabled</c:if>/>--%>
                                    <textarea class="form-control" rows="5" name="industryInfo" <c:if test="${customer.id != null}">disabled</c:if>>${customer.industryInfo}</textarea>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label"></label>
                                <div class="col-sm-6">
                                    <button type="button" onclick="$customer.fn.save()" class="btn btn-primary">保存</button>
                                    <button type="button" class="btn btn-primary" onclick="$customer.fn.back()">返回</button>
                                </div>
                            </div>

                        </form>
                    </div>
                    <!-- /.panel-body -->

                </div>
                <!-- /.panel -->
            </div>
        </div>

    </div>
    <!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

<!-- 配置文件 -->

</body>

<%@ include file="../inc/footer.jsp" %>
<script>
    $customer = {
        v: {
            list: [],
            chart: null,
            dTable: null
        },
        fn: {
            init: function () {

            },
            save : function() {
                if(!$("#formId").isValid()) return;
                $("#formId").ajaxSubmit({
                    url : "${contextPath}/admin/customer/save",
                    type : "POST",
                    success : function(result) {
                        if(result.status == 0) {
                            $customer.fn.back();
                        }else {
                            $leoman.alertMsg(result.msg);
                        }
                    }
                });
            },
            back : function(){
                window.location.href = "${contextPath}/admin/customer/index";
            }
        }
    }
    $(function () {
        $customer.fn.init();
    })
</script>

</html>